
function unary(fn) {
    console.info(fn.length);
    return function oneArg(arg){
        return fn( arg );//解读为改造方法签名
    };
}
//unary的作用将函数改造成只接收一个参数的函数
["1","2","3","4","5"].map( unary( parseInt ) ); // [1,2,3,4,5]


[5,10,15].reduce( (arr,val) => arr * val, 3 );

var half = v => v / 2;
[2,4,6,8,10].map( half ); // [1,2,3,4,5]

[2,4,6,8,10].reduce(
    (list,v) => (
        list.push( half( v ) ),
        list
    ), []
); // [1,2,3,4,5]



var isEven = v => v % 2 == 0;
[1,2,3,4,5].filter( isEven ); // [2,4]

[1,2,3,4,5].reduce(
    (list,v) => (
        isEven( v ) ? list.push( v ) : undefined,
        list
    ), []
); // [2,4]


var half = v => v / 2;
[2,4,6,8,10].reduce(
    (list,v) => (
        list.push( half( v ) )
    ), []
);

//array.map是一个 functor，它有一组值，map方法可以作用于数组里面的每一个值，提供了一个映射的功能
function Just(val) {
    return { map };
    function map(fn) { return Just( fn( val ) ); }
}

var A = Just( 10 );
var B = A.map( v => v * 2 ); // 20


